<template>
    <div class="app-container">
        <TableCard>
            <el-table
                :border="Global.tableShowBorder"
                v-loading="loading"
                :data="scoreList"
                @selection-change="handleSelectionChange"
            >
                <el-table-column
                    label="观察点"
                    align="center"
                    prop="pointName"
                    :align="'center'"
                />
                <el-table-column label="考试成绩" :align="'center'">
                    <el-table-column :label="scoreScaleLabel" :align="'center'">
                        <el-table-column
                            prop="scoreTotal"
                            label="考试总分"
                            :align="'center'"
                        ></el-table-column>
                        <el-table-column
                            prop="scoreAvg"
                            label="考试平均分"
                            :align="'center'"
                        ></el-table-column>
                        <el-table-column
                            prop="scoreTarget"
                            label="考试达成度"
                            :align="'center'"
                        ></el-table-column>
                    </el-table-column>
                </el-table-column>

                <el-table-column label="作业成绩" :align="'center'">
                    <el-table-column :label="jobScaleLabel" :align="'center'">
                        <el-table-column
                            prop="jobTotal"
                            label="作业总分"
                            :align="'center'"
                        ></el-table-column>
                        <el-table-column
                            prop="jobAvg"
                            label="作业平均分"
                            :align="'center'"
                        ></el-table-column>
                        <el-table-column
                            prop="jobTarget"
                            label="作业达成度"
                            :align="'center'"
                        ></el-table-column>
                    </el-table-column>
                </el-table-column>

                <el-table-column label="实验成绩" :align="'center'">
                    <el-table-column :label="expScaleLabel" :align="'center'">
                        <el-table-column
                            prop="expTotal"
                            label="实验总分"
                            :align="'center'"
                        ></el-table-column>
                        <el-table-column
                            prop="expAvg"
                            label="实验平均分"
                            :align="'center'"
                        ></el-table-column>
                        <el-table-column
                            prop="expTarget"
                            label="实验达成度"
                            :align="'center'"
                        ></el-table-column>
                    </el-table-column>
                </el-table-column>
                <el-table-column
                    label="观察点权重"
                    :align="'center'"
                    prop="scale"
                />
                <el-table-column
                    label="总评总分"
                    :align="'center'"
                    prop="lessonTotal"
                />
                <el-table-column
                    label="总评平均分"
                    :align="'center'"
                    prop="lessonAvg"
                />
                <el-table-column
                    label="总评达成度"
                    :align="'center'"
                    prop="lessonTarget"
                />
            </el-table>
        </TableCard>
    </div>
</template>

<script>
import { calcLessonPointTarget } from "@/api/stu/score";

export default {
    name: "viewLessonPointTarget",
    data() {
        return {
            // 遮罩层
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示查询条件
            showSearch: true,
            // 总条数
            total: 0,
            // 统计信息
            scoreList: [],
            // 弹出层标题
            title: "",
            // 是否显示弹出层
            open: false,
            // 查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 20,
                studentId: null,
                lessonId: null,
                pointId: null,
                score: null,
            },
            // 表单参数
            form: {},
            // 表单校验
            rules: {},
            lessonId: null,
            scoreScaleLabel: "",
            jobScaleLabel: "",
            expScaleLabel: "",
        };
    },
    created() {
        const lessonId = this.$route.params && this.$route.params.lessonId;
        console.log(lessonId);
        if (lessonId) {
            this.lessonId = lessonId;
            this.getList();
        }
    },
    methods: {
        /** 查询学生成绩列表 */
        getList() {
            this.loading = true;
            calcLessonPointTarget(this.lessonId).then((res) => {
                this.loading = false;
                if (res.code == 200) {
                    let data = res.data;
                    this.scoreList = data.listData;
                    this.scoreScaleLabel = "考试权重" + data.scoreScale;
                    this.jobScaleLabel = "作业权重" + data.jobScale;
                    this.expScaleLabel = "实验权重" + data.expScale;
                }
            });
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map((item) => item.id);
            this.single = selection.length !== 1;
            this.multiple = !selection.length;
        },
        /** 新增按钮操作 */
        handleAdd() {
            this.reset();
            this.open = true;
            this.title = "添加学生成绩";
        },
    },
};
</script>
